package com.bestcem.xm.ticket.entity.mongo;

import com.bestcem.xm.ticket.constant.ColumnConstant;
import com.bestcem.xm.ticket.enums.TicketNotifyConfigEventEnum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.List;

/**
 * 工单通知人配置, 记录所有抄送人的信息
 * 问卷项目->开启提醒->工单规则->具体工单规则->跟进处理->(仅通知->抄送|通知且跟进->设置抄送对象)
 * 一个工单规则配置对应多条工单通知人配置
 *
 * @author liheng
 * @version v1.0
 * @date 2021/8/16 14:26
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class TicketNotifyConfig extends BaseEntity {

    private static final long serialVersionUID = 126198371834674177L;
    /**
     * 组织id
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ORG_ID)
    private String orgId;
    /**
     * 工单配置id
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.TICKET_CONFIG_ID)
    private String ticketConfigId;
    /**
     *
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.IS_INSTANT)
    private Boolean instant;
    /**
     *
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.STATUS)
    private Integer status;
    /**
     *
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.MODE)
    private Integer mode;
    /**
     *
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.PERIOD)
    private List<Integer> period;
    /**
     * @see TicketNotifyConfigEventEnum
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.EVENT)
    private Integer event;
    /**
     * 跟进逾期前 hoursLimit 小时通知设置
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.HOURS_LIMIT)
    private Integer hoursLimit;
    /**
     *
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.HAS_RECEIVER)
    private Boolean hasReceiver;
    /**
     *
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.HAS_CC_LIST)
    private Boolean hasCcList;
    /**
     *
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RECEIVER)
    private List<ReceiveUser> receiverList;
    /**
     *
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.CC_LIST)
    private List<RoleRegion> ccList;
    /**
     * 自定义数据
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.CUSTOM_ATTR)
    private TicketRecord.CustomAttr customAttr;
    /**
     * 通知方式
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.WAYS)
    private NotifySetting.Way ways;
    /**
     * 邮箱id
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.SMTP_ID)
    private String smtpId;
    /**
     * 是否sample
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.SAMPLE)
    private Boolean sample;
    /**
     * 邮件主题
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.EMAIL_SUBJECT)
    private String emailSubject;
    /**
     * 邮件内容
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.EMAIL_CONTENT)
    private String emailContent;
    /**
     * 邮件模板id
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.EMAIL_TEMPLATE_ID)
    private String emailTemplateId;
    /**
     * 短信主题
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.SMS_SUBJECT)
    private String smsSubject;
    /**
     * 短信内容
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.SMS_CONTENT)
    private String smsContent;
    /**
     * 短信模板id
     */
    @JsonProperty(value = ColumnConstant.TicketNotifyConfig.SMS_TEMPLATE_ID)
    private String smsTemplateId;


    @Data
    public static class RoleRegion implements Serializable {

        private static final long serialVersionUID = -6154874926355185513L;
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.REGION)
        private String region;

        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.ROLE_ID)
        private String roleId;

        /**
         * 邮箱地址
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.EMAIL)
        private String email;

        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.ID)
        private String id;

        /**
         * 用户名
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.USER_NAME)
        private String userName;

        /**
         * 用户姓名
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.NAME)
        private String name;

        /**
         * 用户手机号
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.MOBILE)
        private String mobile;

        /**
         * 用户状态值
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.STATUS)
        private Integer status;

        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.CC_FILTER)
        private Integer ccFilter;

        /**
         * 用户手机号
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.RoleRegion.CC_ID)
        private String ccId;
    }

    @Data
    public static class ReceiveUser implements Serializable {

        private static final long serialVersionUID = 5137264982234579806L;

        /**
         * 邮箱地址
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ReceiveUser.EMAIL)
        private String email;

        /**
         * 用户id
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ReceiveUser.ID)
        private String id;

        /**
         * 用户手机号
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ReceiveUser.MOBILE)
        private String mobile;
        /**
         * 用户名
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ReceiveUser.USERNAME)
        private String userName;
        /**
         * 区域
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ReceiveUser.REGION)
        private String region;
        /**
         * 角色id
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ReceiveUser.ROLE_ID)
        private String roleId;
        /**
         * followerFilter
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ReceiveUser.FOLLOWER_FILTER)
        private int followerFilter;
        /**
         * followerId
         */
        @JsonProperty(value = ColumnConstant.TicketNotifyConfig.ReceiveUser.FOLLOWER_ID)
        private String followerId;
    }
}
